package shopping;

public class SilverCardMember extends Member {
    private double totalCost = 0;
    private double points = 0;

    public SilverCardMember(String info) {
        super(info);
    }

    @Override
    public double consume(int amount) {
        double actualPayment = amount;
        
        if (points >= 1000) {
            int pointsToUse = (int) points - 1000;
            double discount = pointsToUse * 1.5;
            if (discount > amount) {
                discount = amount;
            }
            actualPayment = amount - discount;
            points = 1000;  // Keep the base 1000 points
        }
        
        // Add new points
        if (actualPayment > 10000) {
            points += (actualPayment - 10000) * 1.5 + 10000;
        } else {
            points += actualPayment;
        }
        
        totalCost += actualPayment;
        return actualPayment;
    }

    @Override
    public String toString() {
        return String.format("SilverCardMember: %s %c %d points=%.1f", 
            getMemberId(), getGender(), getAge(), points);
    }

    @Override
    public double getTotalCost() {
        return totalCost;
    }
} 